package model

import (
	"encoding/json"
	"github.com/shopspring/decimal"
	"matching/enum"
)

type ExchangeTrade struct {
	Symbol string				 `json:"symbol"`
	Price decimal.Decimal		 `json:"price"`
	Amount decimal.Decimal		 `json:"amount"`
	Turnover decimal.Decimal 	 `json:"turnover"`
	Side enum.OrderSide			 `json:"side"`
	BuyOrderId string			 `json:"buyOrderId"`
	SellOrderId string			 `json:"sellOrderId"`
	Timestamp int64				 `json:"timestamp"`
	BuyerId string				 `json:"buyerId"`
	SellerId string				 `json:"sellerId"`
}

func (trade *ExchangeTrade) ToJson() string {
	data, err := json.Marshal(trade)
	if err==nil {
		return string(data)
	}else {
		return ""
	}
}